﻿using System.Linq;
using FwtXnaGame3.Common;
using GpgCore.Products;

namespace GpgCore.GameWorld
{
    public class PeopleNeedsManager
    {
        public SmartDictionary<ProductType, PeopleNeed> Needs;

        public PeopleNeedsManager()
        {
            Needs = new SmartDictionary<ProductType, PeopleNeed>();

            //TODO: fill all human needs
            Needs.Add(ProductType.Food, new PeopleNeed
                                            {
                                                ProductType = ProductType.Food,
                                                DailyIncrement = 1, 
                                                Delta = -0.01,
                                                MinIncrement = 0.5,
                                                MaxIncrement = 2.5,
                                                SatisfactionInfluence = 0.001
                                            });
            Needs.Add(ProductType.Medicals, new PeopleNeed
                                            {
                                                ProductType = ProductType.Medicals,
                                                DailyIncrement = 1, 
                                                Delta = -0.01,
                                                MinIncrement = 0.1,
                                                MaxIncrement = 10,
                                                SatisfactionInfluence = 0.005
                                            });
        }
    
        public void CalcValues()
        {
            var sum = Needs.Sum(p => p.Value.TotalAmount);
            foreach (var need in Needs)
                need.Value.TotalNeedPercent = need.Value.TotalAmount/sum;
        }
    }
}
